/* Author: David McCoy dave.mccoy@cospandesign.com
 *
 *     This file is part of DLCM\SubServ.
 *
 *  DLCM\SubServ is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  DLCM\SubServ is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with DLCM\SubServ.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*
 * Provider.java
 *
 * User Interface for PubSub
 * All control data is routed through here
 * LCM messages are received here
 *
 * Created on Mar 21, 2010, 4:37:49 AM
 */

package com.cospandesign.gui.pubsub;

import com.cospandesign.gui.Main;
import dlcm.StructureManager;
import java.awt.Color;
import java.util.Random;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import pubsub.PubSubController;
import pubsub.PubSubViewListener;

public class PubSubProvider extends javax.swing.JFrame implements PubSubViewListener{
    Main Parent;
    String Name;
    Integer StatusLevel;

    Color PubSubColor;
    String ProviderString;
    boolean ListenToSelfFlag = false;

    //LCM mLCM;
    //DLCM mDLCM;
    //long BoardId = 0;
    //PubSubInfo PSISelf;
    StructureManager mStructureManager;
    //PubSubManager mPubSubManager;
    //ArrayList <String> ChannelStrings;
    //HashMap <String, PubSub> PubSubMap;
    //HashMap <String, ArrayList<String>> PubSubChannelRefMap;
    PubSubController mPubSubController;

    boolean processingReceive = false;


    // <editor-fold defaultstate="collapsed" desc="Constructor/Initialization">
    //public PubSubProvider(Main parent, String name, LCM lcm, StructureManager structureManager, Color color) {
    public PubSubProvider (Main parent, String name, String provider, StructureManager structureManager, Color color){
        initComponents();

        Parent = parent;
        Name = name;
        PubSubColor = color;
        PubSubToolbar.setBackground(color);
        StatusLevel = 0;

        //ChannelStrings = new ArrayList<String>();
        //PubSubMap = new HashMap<String, PubSub>();
        //BoardId = structureManager.getBoardID();
        mPubSubController = new PubSubController(name, structureManager, provider);
        mPubSubController.addPubSubViewListener(this);
//        mPubSubManager = mPubSubController.getPubSubManager();


        //PubSubChannelRefMap = new HashMap<String, ArrayList<String>>();
        //AddChannelsToPubSubReference(name, null);
        //PubSubChannelRefMap.put(name, new ArrayList<String>());

//        mLCM = lcm;
        //PSISelf = new PubSubInfo();
        mStructureManager = structureManager;
        setTitle(name);


        PubSubDebug(getFilterLevelString());
        PubSubDebug("Entered SubPub Controller");
        PubSubImportant("LCM successfully started");

        //SetupComm();
        
        //DLCM is setup in the function above
        //PubSub psi = new PubSub(name, BoardId, mDLCM);
        //PubSubMap.put(name, psi);
        //mPubSubManager = new PubSubManager(mLCM, mDLCM, structureManager);
        //mPubSubManager.AddPubSub(Name, BoardId);

        //Setup GUI functions
        this.PubSubsList.addListSelectionListener(new ListSelectionListener(){

            public void valueChanged(ListSelectionEvent e) {
                PubSubListener();
            }

        });
        this.ChannelList.addListSelectionListener(new ListSelectionListener(){

            public void valueChanged(ListSelectionEvent e) {
                ChannelListListener();
            }
            
        });
        this.MemberList.addListSelectionListener(new ListSelectionListener() {

            public void valueChanged(ListSelectionEvent e) {
                MemberListListener();
            }
            
        });
        this.WidgetList.addListSelectionListener(new ListSelectionListener(){

            public void valueChanged(ListSelectionEvent e) {
                WidgetListListener();
            }

        });
        //Setup Add Remove Channels
        this.StructureList.addListSelectionListener(new ListSelectionListener(){

            public void valueChanged(ListSelectionEvent e) {
                StructureListListener();
            }
        });
        //put myself on the list
        UpdatePubSubsList();
        MainStructureMapChanged();
    }

    public String getChildName(){
        return Name;
    }

    public void setProviderString (String ProviderString){
        this.ProviderString = ProviderString;
        this.setTitle(Name + ": " + ProviderString );
    }

    //Provider Functions
     // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Lists">
    private void UpdatePubSubsList (){
        PubSubsList.setListData(mPubSubController.getPubSubNamesListData());
    }
    private void PubSubListener (){
        String pubSubName = (String) PubSubsList.getSelectedValue();
        if (PubSubsList.getSelectedIndex() == -1){
            ClearChannelList();
            ClearMemberList();
            ClearWidgetList();
            return;
        }
        ChannelList.setListData(mPubSubController.getChannelsListData(pubSubName));
    }
    private void ChannelListListener(){
        String pubSubName = (String) PubSubsList.getSelectedValue();
        String channelName = (String) ChannelList.getSelectedValue();
        if (ChannelList.getSelectedIndex() == -1){
            ClearMemberList();
            ClearWidgetList();
            return;
        }
        MemberList.setListData(mPubSubController.getMembersListData(pubSubName, channelName));
    }
    private void MemberListListener(){
        //Disable the create widgets buttons
        CreateWidgetButton.setEnabled(false);
        RemoveWidgetButton.setEnabled(false);

       if (MemberList.getSelectedIndex() == -1){
           ClearWidgetList();
           return;
       }
       

        String pubSubName = (String) PubSubsList.getSelectedValue();
        String channelName = (String) ChannelList.getSelectedValue();
        String memberName = (String) MemberList.getSelectedValue();
        try {
            //We have the member name, and the channel, from this we can get the structure
            //It doesn't matter if the channel was made locally you can do send and receive on it
            WidgetList.setListData(mPubSubController.getWidgetsListData(pubSubName, channelName, memberName));
        } catch (Exception ex) {
            PubSubError(ex.getMessage());
        }
    }
    private void WidgetListListener(){

        String pubSubName = (String) PubSubsList.getSelectedValue();
        String channelName = (String) ChannelList.getSelectedValue();
        String memberName = (String) MemberList.getSelectedValue();


        CreateWidgetButton.setEnabled(true);
        RemoveWidgetButton.setEnabled(true);
    }

    private void ClearChannelList(){
        Object[] obs = new Object[0];
        ChannelList.setListData(obs);
    }
    private void ClearMemberList(){
        Object[] objs = new Object[0];
        MemberList.setListData(objs);
    }
    private void ClearWidgetList(){
        Object[] obs = new Object[0];
        WidgetList.setListData(obs);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Add Remove Channels Dialog">
    private void StructureListListener(){
        String structureName = (String) StructureList.getSelectedValue();
        if (structureName == null){
            StructureNameLabel.setText("Nothing Selected");
            AddChannel.setEnabled(false);
            ChannelNameTextField.setText("");
            return;
        }

        StructureNameLabel.setText(structureName);
        AddChannel.setEnabled(true);
        String channelName = GenerateRandomChannelName();
        while (mPubSubController.getChannel(channelName) != null){
            //perhaps overkill
            channelName = GenerateRandomChannelName();
        }
        ChannelNameTextField.setEnabled(true);
        ChannelNameTextField.setText(channelName);

    }
    private void InstanceListListener(){
        if (InstanceList.getSelectedIndex() == -1){
            RemoveInstanceButton.setEnabled(false);
            RemoveAllInstancesButton.setEnabled(false);
            return;
        }
        RemoveInstanceButton.setEnabled(true);
        RemoveAllInstancesButton.setEnabled(true);
    }
    private String GenerateRandomChannelName(){
        String channelName = new String("channel");
        Integer i = new Random().nextInt(1000);
        channelName += i.toString();
        return channelName;
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="PubSubViewListner Functions">

    public void pscFatal(String message) {
        setStatus(message);
    }

    public void pscError(String message) {
        setStatus(message);
    }

    public void pscWarning(String message) {
        setStatus(message);
    }

    public void pscImportant(String message) {
        setStatus(message);
    }

    public void pscInfo(String message) {
        setStatus(message);
    }

    public void pscDebug(String message) {
        setStatus(message);
    }

    public void pscVerbose(String message) {
        setStatus(message);
    }
    public void pscChanged() {
        UpdatePubSubsList();
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Structure Manager Listener">
    public void MainStructureMapChanged(){
        Object[] structureNames = new Object[mStructureManager.StructureMap.size()];
        structureNames = mStructureManager.StructureMap.keySet().toArray();
        StructureList.setListData(structureNames);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Status Messages">
    public void FilterLevelChanged (String level){
        setStatus("Status Level Changed to " + level);
    }

    private void PubSubFatal (String fatal){
        if (StatusLevel <= 5){
            setStatus("Fatal: " + fatal);
        }
    }
    private void PubSubError (String error){
        if (StatusLevel <= 4){
            setStatus("Error: " + error);
        }
    }
    private void PubSubWarning (String warning){
        if (StatusLevel <= 3){
            setStatus("Warning: " + warning);
        }
    }
    private void PubSubImportant (String important){
        if (StatusLevel <= 2){
            setStatus("Important: " +important);
        }
    }
    private void PubSubInfo (String info){
        if (StatusLevel <= 1){
            setStatus("Info: " +info);
        }
    }
    private void PubSubDebug (String debug){
        setStatus("Debug: " + debug);
    }
    public void setStatus(String status){
        StatusMessageBox.append(status + "\n");
    }

    public String getFilterLevelString(){
        return (String) FilterComboBox.getSelectedItem();
    }
    //</editor-fold>

// <editor-fold defaultstate="collapsed" desc="AutoGen Functions">
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        addRemoveDialog = new javax.swing.JDialog();
        jPanel4 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        ChannelNameTextField = new javax.swing.JTextField();
        AddChannel = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        StructureNameLabel = new javax.swing.JLabel();
        RemoveInstanceButton = new javax.swing.JButton();
        RemoveAllInstancesButton = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        InstanceList = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        StructureList = new javax.swing.JList();
        jLabel4 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        PubSubToolbar = new javax.swing.JToolBar();
        AddRemoveInstanceButton = new javax.swing.JToggleButton();
        jPanel7 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        ChannelList = new javax.swing.JList();
        SubscrbieToChannelButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        ViewRawButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        MemberList = new javax.swing.JList();
        jPanel1 = new javax.swing.JPanel();
        PingButton = new javax.swing.JButton();
        RequestChannelsButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        PubSubsList = new javax.swing.JList();
        SelectAllPubSubs = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        WidgetList = new javax.swing.JList();
        CreateWidgetButton = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        RemoveWidgetButton = new javax.swing.JButton();
        WidgetInputRadio = new javax.swing.JRadioButton();
        WidgetOutputRadio = new javax.swing.JRadioButton();
        jPanel6 = new javax.swing.JPanel();
        ChatButton = new javax.swing.JButton();
        PublishTextField = new javax.swing.JTextField();
        FilterSelfChatCheckBox = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        FilterComboBox = new javax.swing.JComboBox();
        StatusBox = new javax.swing.JScrollPane();
        StatusMessageBox = new javax.swing.JTextArea();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        addRemoveDialog.setTitle("Add/Remove Local Channels");
        addRemoveDialog.setMinimumSize(new java.awt.Dimension(325, 450));
        addRemoveDialog.setResizable(false);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Instance Settings"));

        jLabel3.setText("Channel Name");

        ChannelNameTextField.setToolTipText("Instance Names May have a number appended if there is a name collision");
        ChannelNameTextField.setEnabled(false);

        AddChannel.setText("Add");
        AddChannel.setEnabled(false);
        AddChannel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddChannelActionPerformed(evt);
            }
        });

        jLabel5.setText("Structure");

        StructureNameLabel.setText("Nothing Selected");

        RemoveInstanceButton.setText("Remove");
        RemoveInstanceButton.setEnabled(false);
        RemoveInstanceButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RemoveInstanceButtonActionPerformed(evt);
            }
        });

        RemoveAllInstancesButton.setText("Remove All");
        RemoveAllInstancesButton.setEnabled(false);
        RemoveAllInstancesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RemoveAllInstancesButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3)
                    .addComponent(StructureNameLabel))
                .addGap(58, 58, 58)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(AddChannel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                    .addComponent(ChannelNameTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                    .addComponent(RemoveInstanceButton, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                    .addComponent(RemoveAllInstancesButton, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(ChannelNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(StructureNameLabel))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(AddChannel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(RemoveInstanceButton)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(RemoveAllInstancesButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jScrollPane4.setViewportView(InstanceList);

        StructureList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane5.setViewportView(StructureList);

        jLabel4.setText("Structures");

        jLabel7.setText("Channels");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane5)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout addRemoveDialogLayout = new javax.swing.GroupLayout(addRemoveDialog.getContentPane());
        addRemoveDialog.getContentPane().setLayout(addRemoveDialogLayout);
        addRemoveDialogLayout.setHorizontalGroup(
            addRemoveDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(addRemoveDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(addRemoveDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        addRemoveDialogLayout.setVerticalGroup(
            addRemoveDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(addRemoveDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("LCM/DLCM Publisher/Subscriber (PubSub)");
        setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/cospandesign/resources/cospandesign.png")));
        setLocationByPlatform(true);
        setName("SubPub"); // NOI18N
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                PubSubProvider.this.windowClosing(evt);
            }
        });

        PubSubToolbar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        PubSubToolbar.setRollover(true);

        AddRemoveInstanceButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/cospandesign/gui/resources/instanceAddRemove.png"))); // NOI18N
        AddRemoveInstanceButton.setFocusable(false);
        AddRemoveInstanceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        AddRemoveInstanceButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        AddRemoveInstanceButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddRemoveInstanceButtonActionPerformed(evt);
            }
        });
        PubSubToolbar.add(AddRemoveInstanceButton);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Channels"));

        ChannelList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(ChannelList);

        SubscrbieToChannelButton.setText("Subscribe");
        SubscrbieToChannelButton.setToolTipText("Subscribe to the selected channel(s)");
        SubscrbieToChannelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SubscrbieToChannelButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(SubscrbieToChannelButton, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(SubscrbieToChannelButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Structures"));

        ViewRawButton.setText("View Raw");
        ViewRawButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ViewRawButtonActionPerformed(evt);
            }
        });

        jScrollPane3.setViewportView(MemberList);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ViewRawButton, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(ViewRawButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("PubSubs"));

        PingButton.setText("Ping/Query");
        PingButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PingButtonActionPerformed(evt);
            }
        });

        RequestChannelsButton.setText("Request Channels");
        RequestChannelsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RequestChannelsButtonActionPerformed(evt);
            }
        });

        PubSubsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(PubSubsList);

        SelectAllPubSubs.setText("Select All");
        SelectAllPubSubs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectAllPubSubsActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PingButton, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
            .addComponent(SelectAllPubSubs, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
            .addComponent(RequestChannelsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(PingButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SelectAllPubSubs)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(RequestChannelsButton))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Widgets"));

        jScrollPane6.setViewportView(WidgetList);

        CreateWidgetButton.setText("Create");
        CreateWidgetButton.setEnabled(false);
        CreateWidgetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CreateWidgetButtonActionPerformed(evt);
            }
        });

        jButton2.setText("Show/Hide");

        RemoveWidgetButton.setText("Remove");
        RemoveWidgetButton.setEnabled(false);
        RemoveWidgetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RemoveWidgetButtonActionPerformed(evt);
            }
        });

        WidgetInputRadio.setSelected(true);
        WidgetInputRadio.setText("in");
        WidgetInputRadio.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);

        WidgetOutputRadio.setSelected(true);
        WidgetOutputRadio.setText("out");
        WidgetOutputRadio.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
            .addComponent(RemoveWidgetButton, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(WidgetInputRadio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
                .addComponent(WidgetOutputRadio)
                .addContainerGap())
            .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
            .addComponent(CreateWidgetButton, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(WidgetOutputRadio)
                    .addComponent(WidgetInputRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(CreateWidgetButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(RemoveWidgetButton))
        );

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        ChatButton.setText("Chat");
        ChatButton.setToolTipText("Pressing Enter in the text box will send");
        ChatButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ChatButtonActionPerformed(evt);
            }
        });

        PublishTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                PublishTextFieldKeyPressed(evt);
            }
        });

        FilterSelfChatCheckBox.setSelected(true);
        FilterSelfChatCheckBox.setText("Filter Self Chat");
        FilterSelfChatCheckBox.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        FilterSelfChatCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FilterSelfChatCheckBoxActionPerformed(evt);
            }
        });

        jLabel1.setText("Status");

        jLabel2.setText("Filter");

        FilterComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Debug", "Info", "Important", "Warning", "Error", "Fatal" }));
        FilterComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FilterComboBoxActionPerformed(evt);
            }
        });

        StatusMessageBox.setColumns(20);
        StatusMessageBox.setEditable(false);
        StatusMessageBox.setRows(5);
        StatusBox.setViewportView(StatusMessageBox);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(StatusBox, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ChatButton)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(FilterSelfChatCheckBox)
                                .addGap(39, 39, 39)
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                                .addComponent(FilterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(PublishTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ChatButton)
                    .addComponent(PublishTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(FilterSelfChatCheckBox)
                    .addComponent(jLabel2)
                    .addComponent(FilterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(StatusBox, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
                .addContainerGap())
        );

        fileMenu.setText("File");

        openMenuItem.setText("Open");
        fileMenu.add(openMenuItem);

        saveMenuItem.setText("Save");
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setText("Save As ...");
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setText("Edit");

        cutMenuItem.setText("Cut");
        editMenu.add(cutMenuItem);

        copyMenuItem.setText("Copy");
        editMenu.add(copyMenuItem);

        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setText("Help");

        contentMenuItem.setText("Contents");
        helpMenu.add(contentMenuItem);

        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(PubSubToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 1002, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PubSubToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        Parent.ChildNotifyParentClosing(Name);
        
        this.dispose();
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void windowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_windowClosing
        //mLCM.close();
        mPubSubController.close();
        Parent.ChildNotifyParentClosing(Name);
    }//GEN-LAST:event_windowClosing

    private void AddRemoveInstanceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddRemoveInstanceButtonActionPerformed
        if (addRemoveDialog.isVisible()){
            addRemoveDialog.setVisible(false);
        }
        else {
            addRemoveDialog.setVisible(true);
        }
    }//GEN-LAST:event_AddRemoveInstanceButtonActionPerformed

    private void PingButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PingButtonActionPerformed
        mPubSubController.pingQuery();
    }//GEN-LAST:event_PingButtonActionPerformed

    private void SelectAllPubSubsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectAllPubSubsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_SelectAllPubSubsActionPerformed

    private void RequestChannelsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RequestChannelsButtonActionPerformed
        mPubSubController.channelRequest();
    }//GEN-LAST:event_RequestChannelsButtonActionPerformed

    private void SubscrbieToChannelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SubscrbieToChannelButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_SubscrbieToChannelButtonActionPerformed

    private void ViewRawButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ViewRawButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ViewRawButtonActionPerformed

    private void AddChannelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddChannelActionPerformed
            //Get Structure Name from list
            String structureName = (String) this.StructureList.getSelectedValue();
            //Get the Channel Name from the text box
            String channelName = this.ChannelNameTextField.getText();
            //Add the structure to the mDLCM
            mPubSubController.generateNewChannel(channelName, structureName);
            //mDLCM.generateNewChannel(channelName, structureName);
            //mPubSubManager.getPubSub(Name).AddChannelName(channelName);
            //Update the channel list
            ChannelListListener();
}//GEN-LAST:event_AddChannelActionPerformed

    private void RemoveInstanceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoveInstanceButtonActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_RemoveInstanceButtonActionPerformed

    private void RemoveAllInstancesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoveAllInstancesButtonActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_RemoveAllInstancesButtonActionPerformed

    private void FilterComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FilterComboBoxActionPerformed
        FilterLevelChanged((String)FilterComboBox.getSelectedItem());
}//GEN-LAST:event_FilterComboBoxActionPerformed

    private void FilterSelfChatCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FilterSelfChatCheckBoxActionPerformed
        ListenToSelfFlag = !FilterSelfChatCheckBox.isSelected();
}//GEN-LAST:event_FilterSelfChatCheckBoxActionPerformed

    private void PublishTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_PublishTextFieldKeyPressed
        if (evt.getKeyChar() == evt.VK_ENTER) {
            mPubSubController.sendChatString(this.PublishTextField.getText());
        }
}//GEN-LAST:event_PublishTextFieldKeyPressed

    private void ChatButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChatButtonActionPerformed
        mPubSubController.sendChatString(this.PublishTextField.getText());
}//GEN-LAST:event_ChatButtonActionPerformed

    private void CreateWidgetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CreateWidgetButtonActionPerformed
        if (!WidgetInputRadio.isSelected() && !this.WidgetOutputRadio.isSelected()){
            PubSubInfo("in, out or both must be selected for a widget");
            return;
        }
        String pubSubName = (String) this.PubSubsList.getSelectedValue();
        String channelName = (String) this.ChannelList.getSelectedValue();
        String memberName = (String) this.MemberList.getSelectedValue();
        String widgetName = (String) this.WidgetList.getSelectedValue();
        if ((pubSubName == null) || (channelName == null) || (memberName == null) || (widgetName == null)){
            PubSubError("Widget Values are not set");
            return;
        }
        if (WidgetInputRadio.isSelected() && WidgetOutputRadio.isSelected()){
            try {
                mPubSubController.addInputOutputWidget(pubSubName, channelName, memberName, widgetName);
            } catch (Exception ex) {
                PubSubError(ex.getMessage());
            }
            return;
        }
        if (WidgetInputRadio.isSelected()){
            try {
                mPubSubController.addInputWidget(pubSubName, channelName, memberName, widgetName);
            } catch (Exception ex) {
                PubSubError(ex.getMessage());
            }
        }
        if (WidgetOutputRadio.isSelected()){
            try {
                mPubSubController.addOutputWidget(pubSubName, channelName, memberName, widgetName);
            } catch (Exception ex) {
                PubSubError(ex.getMessage());
            }
        }

    }//GEN-LAST:event_CreateWidgetButtonActionPerformed

    private void RemoveWidgetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RemoveWidgetButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_RemoveWidgetButtonActionPerformed



    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton AddChannel;
    private javax.swing.JToggleButton AddRemoveInstanceButton;
    private javax.swing.JList ChannelList;
    public javax.swing.JTextField ChannelNameTextField;
    private javax.swing.JButton ChatButton;
    private javax.swing.JButton CreateWidgetButton;
    private javax.swing.JComboBox FilterComboBox;
    private javax.swing.JCheckBox FilterSelfChatCheckBox;
    public javax.swing.JList InstanceList;
    private javax.swing.JList MemberList;
    private javax.swing.JButton PingButton;
    private javax.swing.JToolBar PubSubToolbar;
    private javax.swing.JList PubSubsList;
    private javax.swing.JTextField PublishTextField;
    public javax.swing.JButton RemoveAllInstancesButton;
    public javax.swing.JButton RemoveInstanceButton;
    private javax.swing.JButton RemoveWidgetButton;
    private javax.swing.JButton RequestChannelsButton;
    private javax.swing.JButton SelectAllPubSubs;
    protected javax.swing.JScrollPane StatusBox;
    private javax.swing.JTextArea StatusMessageBox;
    public javax.swing.JList StructureList;
    private javax.swing.JLabel StructureNameLabel;
    private javax.swing.JButton SubscrbieToChannelButton;
    private javax.swing.JButton ViewRawButton;
    private javax.swing.JRadioButton WidgetInputRadio;
    private javax.swing.JList WidgetList;
    private javax.swing.JRadioButton WidgetOutputRadio;
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JDialog addRemoveDialog;
    private javax.swing.JMenuItem contentMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    // End of variables declaration//GEN-END:variables



//</editor-fold>
}
